package com.ojoin.trade.t0loan_core.web.monitor;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 15-10-8
 * Time: 下午2:37
 * To change this template use File | Settings | File Templates.
 */
public class ThreadEntry {

    private long begintime;

    private String endtime;

    private long id;

    private StackTraceElement[] stackTrace0 = null;
    private String name;

    private String remoteaddr;

    private String url;

    public void setStackTrace(String stackTrace) {
        this.stackTrace = stackTrace;
    }

    private long costtime=0;

    private String stackTrace=null;

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getRemoteaddr() {
        return remoteaddr;
    }

    public void setRemoteaddr(String remoteaddr) {
        this.remoteaddr = remoteaddr;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    private String method;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }



    public StackTraceElement[] getStackTrace0() {
        return stackTrace0;
    }

    public void setStackTrace0(StackTraceElement[] stackTrace0) {
        this.stackTrace0 = stackTrace0;
    }



    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getBegintime() {
        return begintime;
    }

    public void setBegintime(long begintime) {
        this.begintime = begintime;
    }

    public String getEndtime() {
        return endtime;
    }

    public void setEndtime(String endtime) {
        this.endtime = endtime;
    }

    public void initcosttime(){
        costtime = System.currentTimeMillis() - getBegintime();
        costtime = (costtime < 0 ? 0 : costtime);
    }
    public long getCosttime() {
        return costtime;
    }
    public String getStackTrace() {
        if (stackTrace0 != null && stackTrace0.length > 0) {
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < stackTrace0.length; i++) {
                sb.append(stackTrace0[i].toString());
                sb.append("\n");
            }
            return sb.toString();
        }
        return null;
    }
}
